import QtQuick 2.0

Item {
    id: turnLight
    width: 320
    height: 180

    property bool isLeft: true
    property int tindex: isLeft?2:0
    property int shaRate: 500
    property bool isRuning: true

    Image {
        id: img1
        x: 0
//        anchors.verticalCenter: parent.verticalCenter
//        width: 120
//        height: 180
        scale: isLeft ? 1 : -1
        source: isLeft ? "qrc:/grader/imgs/arrow_1.png" : "qrc:/grader/imgs/arrow_3.png"
        NumberAnimation on x {
            id: imgAn1
            to: isLeft ? -120 : 480
            duration: isLeft ? 500 : 1500
            running: isRuning
        }
        onXChanged: {
            if (x == imgAn1.to){
                x = isLeft ? turnLight.width : 0
                imgAn1.duration = 1500
                imgAn1.restart()
            }
        }
    }

    Image {
        id: img2
        x: 120
//        anchors.verticalCenter: parent.verticalCenter
//        width: 120
//        height: 180
        scale: isLeft ? 1 : -1
//        fillMode: Image.PreserveAspectFit
        source: "qrc:/grader/imgs/arrow_2.png"
        NumberAnimation on x {
            id: imgAn2
            running: isRuning
            to: isLeft ? -120 : 480
            duration: 1000
        }
        onXChanged: {
            if (x == imgAn2.to){
                x = isLeft ? turnLight.width : 0
                imgAn2.duration = 1500
                imgAn2.restart()
            }
        }
    }

    Image {
        id: img3
        x: 240
//        anchors.verticalCenter: parent.verticalCenter
//        width: 120
//        height: 180
        scale: isLeft ? 1 : -1
        source: isLeft ? "qrc:/grader/imgs/arrow_3.png" : "qrc:/grader/imgs/arrow_1.png"
        NumberAnimation on x {
            id: imgAn3
            running: isRuning
            to: isLeft ? -120 : 480
            duration: isLeft ? 1500 : 500
        }
        onXChanged: {
            if (x == imgAn3.to){
                x = isLeft ? turnLight.width : 0
                imgAn3.duration = 1500
                imgAn3.restart()
            }
        }
    }
}
